Public Class adm_findmerchants
    Inherits System.Web.UI.Page
    'Protected WithEvents TheHeader1 As adm_header
    Public Msg, target, sortby As String
    Public aUserSession(13) As String
    Public objvalid As New gaValidation
    Public bLocked As Boolean
    Public nTempRPP, i As Integer
    Public imgpath, currtURL As String
    Protected WithEvents vid As System.Web.UI.WebControls.TextBox
    Public UID, CID, CompanyID As String
    Public sQS, PG, HTMLString, HTMLDispage, HTMLMertList As String
    Public nNumPages, FilteredPG As Integer
    Protected WithEvents Display As System.Web.UI.WebControls.DropDownList
    Protected WithEvents RPP As System.Web.UI.WebControls.DropDownList
    Protected WithEvents btnFind As System.Web.UI.WebControls.Button
    Protected WithEvents btnCancel As System.Web.UI.WebControls.Button
    Protected WithEvents Company As System.Web.UI.WebControls.TextBox
    Public vRs As DataView
    Dim ToggleSort As Boolean = True
#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        
        objValid.getURL(Request.Url.ToString, imgpath, currtURL)

        CID = Request("CompanyID")

        'Dim sessionid As String  'Request.Cookies("UserSession")
    End Sub

    Public Function GetData(ByVal vRs As DataRow) As String
        'Dim strHtml As String
        '      strHtml="
        '   <%	 FOR colctr = 0 to ubound(vRs,2)
        '   viaKLIXID = vRs(0, colctr)
        '   If isnull(viaklixid) Then viaklixID = "&nbsp;"
        '   CompanyID = vRs(1, colctr)
        '   If isnull(CompanyID) Then CompanyID = "&nbsp;"
        '   Merchant_Name = vRs(2, colctr)
        '   If isnull(Merchant_Name) Then Merchant_Name = "&nbsp;"
        '   City = vRs(3, colctr)
        '   If isnull(City) Then City = "&nbsp;"
        '   Contact_Phone1 = vRs(4, colctr)
        '   If isnull(Contact_Phone1) Then Contact_Phone1 = "&nbsp;"
        '   Contact_Email = vRs(5, colctr)
        '   If isnull(Contact_Email) Then Contact_Email = "&nbsp;"
        '   Active = vRs(6, colctr)
        '   If isnull(Active) Then Active = "&nbsp;"
        '   HTMLString = HTMLString & vbCr & vbTab & vbTab & "<tr bgcolor=""" & bgcolor & """>"
        '   HTMLString = HTMLString & "<td valign=""top""><a href=""javascript:merchantcontext('" & CompanyID & "','" & viaKLIXID & "')""><img src=""/Admin/images/merch_mngt_enter_merch_cont.gif"" width=""13"" height=""14"" border=""0"" alt=""Enter Merchant Context""></a></td>"
        '   HTMLString = HTMLString & "<td valign=""top""><a href=""javascript:merchantdetail('" & viaKLIXID & "')"">" & CompanyID & "::" & viaKLIXID & "</a></td>"
        '   HTMLString = HTMLString & "<td valign=""top"">" & Merchant_Name & "</td>"
        '   HTMLString = HTMLString & "<td valign=""top"">" & City & "</td>"
        '   HTMLString = HTMLString & "<td valign=""top"">" & Contact_Phone1 & "</td>"
        '   HTMLString = HTMLString & "<td valign=""top"">" & Contact_Email & "</td>"
        '   HTMLString = HTMLString & "<td valign=""top"" align=""center"">" & active & "</td>"
        'NEXT
        HTMLString = HTMLString & "</tr>"
        Return HTMLString
    End Function

    Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
        'Dim ofindmerchant As MerchantMngt

        'If RPP.SelectedItem.Value = "" Then
        '    Msg = "<div>Enter an Account ID or Merchant Name and select the number of records you would like to appear in your search.</div><br />"
        'Else
        '    FilteredVID = CheckString(SafeString(Request("VID")))
        '    FilteredCompany = CheckString(SafeString(Request("Company")))
        '    Display = Safestring(Request("Display"))
        '    FilteredRPP = CInt(Request("RPP"))
        '    FilteredPG = CInt(Request("PG"))
        '    Filteredsortby = safestring(Request("sortby"))
        '    If Request("action") = "Find" Then
        '        ToggleSort = False
        '    End If

        '    sQS = "?VID=" & Server.UrlEncode(FilteredVID)
        '    sQS = sQS & "&Company=" & Server.UrlEncode(FilteredCompany)
        '    sQS = sQS & "&Display=" & Server.UrlEncode(Display)
        '    sQS = sQS & "&RPP=" & Server.UrlEncode(FilteredRPP)

        '    ofindmerchant = Server.CreateObject("viaMerchAccount.AdminMerchant")
        '    ofindmerchant.DBConnectString = Application("DSN")
        '    ofindmerchant.SessionID = sessionid
        '    oFindmerchant.nPage = FilteredPG
        '    oFindmerchant.nPageRecords = FilteredRPP
        '    nCompanyID = 0
        '    If CInt(aUserSession(cCOMPANY_ID)) > 0 Then
        '        nCompanyID = CInt(aUserSession(cCOMPANY_ID))
        '    End If
        '    'Response.Write FilteredVID & " | " & nCompanyID & " | " & FilteredCompany & " | " & Display & " | " & Filteredsortby
        '    vRs = ofindmerchant.FindMerchant(CStr(FilteredVID), CInt(nCompanyID), CStr(FilteredCompany), CStr(Display), CStr(Filteredsortby), CBool(ToggleSort))
        '    nNumPages = oFindmerchant.nNumPages
        '    ofindmerchant = Nothing
        '    If Not IsNothing(vRs) Then
        '        'GetData(vRs)
        '    End If

        'End If
        'If Request("sortby").count > 0 Then
        '    sQS = sQS & "&sortby=" & Request("sortby")
        'End If
        'TheHeader1.helpaid = "?state=1"
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Response.Redirect("../MerchantMngt/default.aspx")
    End Sub

    Private Sub RPP_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RPP.SelectedIndexChanged
        nTempRPP = 0
        '   If Request("RPP").count > 0 Then
        '       nTempRPP = CInt(Request("RPP"))
        '   End If

        '   For i = 1 To 4 Step 1
        '	if nTempRPP = i * 25 then %>
        '	<option selected="true"><%=i*25%></option>
        '	<%else %>
        '	<option><%=i*25%></option>
        ' <%
        '	 end if
        '   Next
        '%>
        '</select>
    End Sub
    Public Function DrawPaginationControls() As String
        Dim strPageNum As String
        'If 'Request("sortby").count > 0 Then
        'sQS = sQS & "&sortby=" & Request("sortby")
        'End If
        strPageNum = " <table border=""0"" cellspacing=""0"" cellpadding=""0"" align=""center"" width=""100%"">"
        strPageNum += "<tr><td align=""right"" width=""50%"">"


        If FilteredPG > 1 Then
            strPageNum += "<a href=""adm_findmerchants.asp<%=sQS%>&action=Find&PG=<%=FilteredPG - 1%>""><b>PREVIOUS PAGE</b></a>"
        Else
            strPageNum += "&nbsp; "
        End If
        strPageNum += "	</td><td>&nbsp;</td><td nowrap>Displaying Page <%=FilteredPG%> of <%=nNumPages%>.</td><td>&nbsp;</td>"

        strPageNum += "<td align=""left"" width=""50%"">"
        If IsArray(vRs) And nNumPages > FilteredPG Then
            strPageNum += "	<a href=""adm_findmerchants.asp<%=sQS%>&action=Find&PG=<%=FilteredPG + 1%>""><b>NEXT PAGE</b></a>"
        Else
            strPageNum += "&nbsp;"
        End If
        strPageNum += "</td></tr></table>"
        HTMLDispage = strPageNum
        Return HTMLDispage
    End Function
End Class
